<?
/*********************************************
*友情链接
* *******************************************/
function smarty_function_qishi_link($params, &$smarty)
{ 
extract($params);
global $db,$_CFG;
$row = (NULL != $row) ? $row : 60; //默认显示记录数量
$start  = (NULL != $start) ? $start : 0; //从第几条开始读取，缺省0
$titlelen = (NULL != $titlelen) ? $titlelen : 15; //默认显示标题数量
$dot = (NULL != $dot) ? $dot : ''; //默认截取后填补字符
$typeid = (NULL != $typeid) ? $typeid : 1; //栏目ID
$linktype = (NULL != $linktype) ? $linktype : 1; //链接类型
$listname = (NULL != $listname) ? $listname : "list"; //默认的循环变量名称
$wheresql=" WHERE category_id='".$typeid."' ";
($linktype=="1") ? ($wheresql.=" AND  link_logo=''"):'';
($linktype=="2" )? ($wheresql.=" AND  link_logo<>''"):'';
if(!empty($row))
{
$offset=$start?$start:0;
$limit=" LIMIT ".$offset.','.$row;
}
$result = $db->query("SELECT * FROM ".table('link')." ".$wheresql." ORDER BY show_order DESC ".$limit);
while($row = $db->fetch_array($result))
{
$row['title']=cut_str($row['link_name'],$titlelen,0,$dot);
$row['img']=$_CFG['upfiles_dir'].$row['link_logo'];
$List[] = $row;
}
$smarty->assign($listname, $List);
unset($List);
}
?>